package 双指针;

import java.util.Arrays;

public class _005 {
    //611 有效三角形的个数
    public int triangleNumber(int[] nums) {
        Arrays.sort(nums);
        int c=nums.length-1;
        int num=0;
        while(c>=2){
            int left=0;
            int right=c-1;
            while(left!=right){
                if(nums[left]+nums[right]>nums[c]){
                    num += right-left;
                    right--;
                }else{
                    left++;
                }
            }
            c--;
        }
        return num;
    }
}
